﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ManagerEvenements : MonoBehaviour {

	// Properties
	//
	//

	public List<EvenementAleatoire> Evenements;

	public Manager Manager;

	// Methods
	//
	//

	public void ApplyRandomEvent(){

		// Find one random event
		int i = Random.Range(0, this.Evenements.Count);

		// Check if it proc
		int proc = Random.Range(0,100);
		if(this.Evenements[i].Probabilite > proc){

			// TODO : Show textbox

			// Si les conditions de l'evenement sont remplies
			if(this.Evenements[i].CheckCondition(this.Manager)){

				this.Manager.Building += this.Evenements[i].ModifBuild;
				this.Manager.Mood += this.Evenements[i].ModifMood;
				this.Manager.Population += this.Evenements[i].ModifPop;

				this.Manager.StartCoroutine("ShowRandomEvent", new string[2] {this.Evenements[i].Title, this.Evenements[i].Description});
				this.Manager.eventHappened = true;

			}
		}
	}
}
